/*
	Copyright (c) 2008, Grant Jones <grant@podtronics.com>.
	All rights reserved.

	Redistribution and use in source and binary forms, with or
	without modification, are permitted provided that the following
	conditions are met:

		Redistributions of source code must retain the above copyright
		notice, this list of conditions and the following disclaimer.
		
		Redistributions in binary form must reproduce the above copyright
		notice, this list of conditions and the following disclaimer in
		the documentation and/or other materials provided with the
		distribution.
		
		Neither the name of the gxjones.com nor the names of its
		contributors may be used to endorse or promote products derived
		from this software without specific prior written permission.
	
	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
	"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
	LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
	FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
	COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
	INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
	(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
	SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
	STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
	OF THE POSSIBILITY OF SUCH DAMAGE.
	
	http://www.opensource.org/licenses/bsd-license.php
*/

/*
 *  edb_domain_index.h
 *  edb
 *
 *  Created by Grant Jones on 3/24/08.
 *
 */

#ifndef EDB_DOMAIN_INDEX_H
#define EDB_DOMAIN_INDEX_H

/*!
	@function edb_domain_init_index
	@abstract initializes a  domain handles index info
	@discussion called when a domain is opened to find or create indices
	@param d
*/
int edb_domain_init_index( edb_domain_t *d );

/*!
	@function edb_domain_loc_index
	@abstract returns the location where to start enumerating items that are contained in the 
	index of the specified attr_name and attr_val
	@discussion
	@param d
	@param attr_name
	@param attr_val
	@result location to the parent item, 0 if not found or error
*/	
off_t edb_domain_loc_index( edb_domain_t *d, rtvalue_t *attr_name, rtvalue_t *attr_val );

/*!
	@function edb_domain_add_index
	@abstract adds a specific item index for an attribute name and value
	@discussion
	@param d
	@param attr_name
	@param attr_value
	@param item_name
*/
int edb_domain_add_index( edb_domain_t *d, rtvalue_t *attr_name, rtvalue_t *attr_value, rtvalue_t *item_name );

/*!
	@function edb_domain_rm_index
	@abstract removes a specific item index for an attribute name and value
	@discussion
	@param d
	@param attr_name
	@param attr_value
	@param item_name
*/
int edb_domain_rm_index( edb_domain_t *d, rtvalue_t *attr_name, rtvalue_t *attr_value, rtvalue_t *item_name );

/*!
	@function edb_domain_index_item
	@abstract Adds indices for all attributes specified by attr_values
	@discussion This is the generic interface for getting an item indexed
	@param dref
	@param attr_values
	@param item_name
*/
int edb_domain_index_item( edb_domain_ref_t *dref, AttrList *attr_values, rtvalue_t *item_name );

/*!
	@function edb_domain_unindex_item
	@abstract Removes indices for all attributes specified by attr_values
	@discussion This is the generic interface for removing all of an item's indexed values
	@param dref
	@param attr_values
	@param item_name
*/
int edb_domain_unindex_item( edb_domain_ref_t *dref, AttrList *attr_values, rtvalue_t *item_name );


#endif



